package com.domus.dreamMenu.cliente.gui.paineis;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PainelItemListagem extends JPanel {

	public PainelItemListagem(Icon imagemPrato, String nomePrato, ActionListener listener) {
		super(new BorderLayout());
		final JButton bt;
		if(imagemPrato == null)
			bt = new JButton(new ImageIcon("./src/imagens/pratoPequeno"));
		else
			bt = new JButton(imagemPrato);
		bt.addActionListener(listener);
		this.add(bt, BorderLayout.NORTH);
		this.add(new JLabel(nomePrato), BorderLayout.SOUTH);
	}
	
	public static void main(String[] args) {
		JFrame f = new JFrame();
		f.setLayout(new FlowLayout());
		f.setSize(Toolkit.getDefaultToolkit().getScreenSize());
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		

		f.add(new PainelItemListagem(
				new ImageIcon("." + File.separator + "src" + File.separator + "imagens" + File.separator + "pratoPequeno"), 
				"mamamia", 
				new ActionListener(){
					public void actionPerformed(ActionEvent arg0) {
						System.out.println("botao clicado");
					}	
				}));
		
		f.setVisible(true);
	}
}
